﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Client
{
    public partial class AddANewPerson : Form
    {
        /// <summary>
        /// Définit la liste des utilisateurs disponibles
        /// </summary>
        public List<string> Players
        {
            set
            {
                foreach (string val in value)
                {
                    DataGridViewRow dgvr = new DataGridViewRow();
                    //Création des cellules à partir du tableau que l'on souhaite
                    dgvr.CreateCells(this.dataGridView_users);
                    dgvr.Cells[this.LogoColumn.Index].Value = Resource1.user;
                    dgvr.Cells[this.NameUser.Index].Value = val;
                    this.dataGridView_users.Rows.Add(dgvr);
                }
            }
        }

        /// <summary>
        /// Obtient la liste des joueurs sélectionnées
        /// </summary>
        public List<string> SelectedPlayers
        {
            get
            {
                List<string> list = new List<string>();

                foreach (DataGridViewRow dgvr in this.dataGridView_users.SelectedRows)
                {
                    string str = dgvr.Cells[this.NameUser.Index].Value.ToString();

                    if (!list.Contains(str))
                        list.Add(str);
                }

                return list;
            }
        }

        public AddANewPerson()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
